<!DOCTYPE html>
<html lang="en">
<head>
    <title>管理系统 - 管理中心</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- CSS Libs -->
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap-switch.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/checkbox3.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/dataTables.bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/select2.min.css">
    <link href="../lib/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">	
    <!-- CSS App -->
    <link rel="stylesheet" type="text/css" href="../css/style.css">
    <link rel="stylesheet" type="text/css" href="../css/themes/flat-blue.css">
	<style type="text/css">
        .table>tbody>tr>td{height:38px; line-height: 38px}
        .f{ float: left; width:40px; }
        .listInput{ width:150px }
        .bt{ margin-left:15px }
        .pointer{ cursor: pointer }
        .sort{ color:#5bc0de}
        .info{ color:#1b6d85 }
        .danger{ color:#ff0000 }
        .primary{ color:#3c763d }
        .rowEnable{ background-color: #fff }
        .rowDisabled{ background-color: #F7F7F7 }
        .mr{ margin-right: 10px}
        .ml{ margin-left: 10px}
        input[type="text"]{ height:30px; }
        input[type="radio"]{ margin-left:6px }
        select{ height:25px;  }

    </style>
</head>

<body class="flat-blue">
    <div class="app-container">
        <div class="row content-container">
            <nav class="navbar navbar-default navbar-fixed-top navbar-top">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-expand-toggle">
                            <i class="fa fa-bars icon"></i>
                        </button>
                        <ol class="breadcrumb navbar-breadcrumb">
                            <li class="active" style="font-family:仿宋">管理系统</li>
                        </ol>
                        <button type="button" class="navbar-right-expand-toggle pull-right visible-xs">
                            <i class="fa fa-th icon"></i>
                        </button>
                    </div>
                    <ul class="nav navbar-nav navbar-right">
                        <button type="button" class="navbar-right-expand-toggle pull-right visible-xs">
                            <i class="fa fa-times icon"></i>
                        </button>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-comments-o"></i></a>
                            <ul class="dropdown-menu animated fadeInDown">
                                <li class="title">
                                    Notification <span class="badge pull-right">0</span>
                                </li>
                                <li class="message">
                                    No new notification
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown danger">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-star-half-o"></i> 4</a>
                            <ul class="dropdown-menu danger  animated fadeInDown">
                                <li class="title">
                                    Notification <span class="badge pull-right">4</span>
                                </li>
                                <li>
                                    <ul class="list-group notifications">
                                        <a href="#">
                                            <li class="list-group-item">
                                                <span class="badge">1</span> <i class="fa fa-exclamation-circle icon"></i> new registration
                                            </li>
                                        </a>
                                        <a href="#">
                                            <li class="list-group-item message">
                                                view all
                                            </li>
                                        </a>
                                    </ul>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown profile">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Lucy <span class="caret"></span></a>
                            <ul class="dropdown-menu animated fadeInDown">
                                <li class="profile-img">
                                    <img src="../img/profile/picjumbo.com_HNCK4153_resize.jpg" class="profile-img">
                                </li>
                                <li>
                                    <div class="profile-info">
                                        <h4 class="username">Emily Hart</h4>
                                        <p>emily_hart@email.com</p>
                                        <div class="btn-group margin-bottom-2x" role="group">
                                            <button type="button" class="btn btn-default"><i class="fa fa-user"></i> 权限</button>
                                            <button type="button" class="btn btn-default"><i class="fa fa-sign-out"></i> 推出</button>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
            <div class="side-menu sidebar-inverse">
                <nav class="navbar navbar-default" role="navigation">
                    <div class="side-menu-container">
                        <div class="navbar-header">
                            <a class="navbar-brand" href="#">
                                <div class="icon fa fa-cloud"></div>
                                <div class="title">Cloud Platform</div>
                            </a>
                            <button type="button" class="navbar-expand-toggle pull-right visible-xs">
                                <i class="fa fa-times icon"></i>
                            </button>
                        </div>
                        <ul class="nav navbar-nav">
                            <li class="">
                                <a href="index.html">
                                    <span class="icon fa fa-desktop"></span><span class="title">控制台</span>
                                </a>
                            </li>
                            <li class="panel panel-default dropdown">
                                <a data-toggle="collapse" href="#dropdown-element">
                                    <span class="icon fa fa-wrench"></span><span class="title">表单管理</span>
                                </a>
                                <!-- Dropdown level 1 -->
                                <div id="dropdown-element" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <ul class="nav navbar-nav">
                                            <li><a href="formConfig.html">表单设置</a>
                                            </li>
                                            <li><a href="#">其它设置</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </li>
                            <li class="panel panel-default dropdown">
                                <a data-toggle="collapse" href="#dropdown-data">
                                    <span class="icon fa fa-database"></span><span class="title">数据管理</span>
                                </a>
                                <!-- Dropdown level 1 -->
                                <div id="dropdown-data" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <ul class="nav navbar-nav">
                                            <li><a href="formDevice.html">数据录入</a>
                                            </li>
                                            <li><a href="showDevice.html">数据管理</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </li>
                            <!-- Dropdown-->
                            <li class="panel panel-default dropdown">
                                <a data-toggle="collapse" href="#dropdown-chart">
                                    <span class="icon fa fa-area-chart"></span><span class="title">数据分析</span>
                                </a>
                                <!-- Dropdown level 1 -->
                                <div id="dropdown-chart" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <ul class="nav navbar-nav">
                                            <li><a href="chartMap.html">地理分布</a>
                                            </li>
                                            <li><a href="companyList.html">公司信息</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </li>
                            <li class="panel panel-default dropdown">
                                <a data-toggle="collapse" href="#dropdown-user">
                                    <span class="icon fa fa-user"></span><span class="title">用户管理</span>
                                </a>
                                <!-- Dropdown level 1 -->
                                <div id="dropdown-user" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <ul class="nav navbar-nav">
                                            <li><a href="pages/login.html">用户列表</a>
                                            </li>
                                            <li><a href="pages/index.html">权限管理</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <!-- /.navbar-collapse -->
                </nav>
            </div>
            <div class="copyrights">Collect from <a href="http://www.cssmoban.com/" >免费网站模板</a></div>
            <!-- Main Content -->
            <div class="container-fluid" ng-app="myApp" ng-controller="myCtrl">
                <div class="side-body padding-top" style="background-color:#fff; bottom: 20px; position:absolute; top:10px; left:10px; right:10px">
                    
                    <div class="row " style="background-color:#fff">
					
                        <!------------------------------------------------------------------>
						<div style="width:90%; margin:10px" compile="formTpl" class="col-sm-12 col-xs-12">
		
	
					</div>
    </div>
<!---------------------------------------------------------------------------->
						
						
                    </div>
					<div class="row  no-margin-bottom">
					</div>
                </div>
            </div>
        </div>
        <footer class="app-footer">
            <div class="wrapper">
                <span class="pull-right">2.1 <a href="#"><i class="fa fa-long-arrow-up"></i></a></span> © 2015 Copyright. More Templates <a href="http://www.cssmoban.com/" target="_blank" title="">**科技有限公司</a> - Collect from <a href="#" title="管理系统" target="_blank">管理系统</a>
            </div>
        </footer>
        <div>
            <!-- Javascript Libs -->
            <script type="text/javascript" src="../lib/js/jquery.min.js"></script>
            <script type="text/javascript" src="../lib/js/bootstrap.min.js"></script>
            <script type="text/javascript" src="../lib/js/bootstrap-switch.min.js"></script>
            <script type="text/javascript" src="../lib/js/jquery.matchHeight-min.js"></script>
            <script type="text/javascript" src="../lib/js/jquery.dataTables.min.js"></script>
            <script type="text/javascript" src="../lib/js/dataTables.bootstrap.min.js"></script>
            <script type="text/javascript" src="../lib/js/select2.full.min.js"></script>
            <script src="../lib/js/bootstrap-datetimepicker.min.js"></script>
			<script src="../lib/js/bootstrap-datetimepicker.zh-CN.js"></script>
			

            <!-- Javascript -->
            <script type="text/javascript" src="../js/app.js"></script>
            <script type="text/javascript" src="../js/index.js"></script>
			<script type="text/javascript" src="../lib/js/angular.min.js"></script>
			<script type="text/javascript" src="../js/public.js"></script>
			<script type="text/javascript" src="../js/chinaZone.js"></script>
			<script type="text/javascript" src="../js/editDevice.js"></script>
<script language="javascript">
    function cout(obj){ console.log(obj); }

    var app = angular.module('myApp', []);
    
    app.controller('myCtrl', function($scope, ) {
        $scope.formTpl = getEditDeviceTpl.txtContent();
        //// 单条数据
        $scope.line = {"id":-1,"type":"工业", "productionStatus":"未投产"};
        //// 地址信息·支持多字段
        $scope.Addrs = {};
        ajaxData("get_form", {"user":'David'}, function(rst){ cout(rst);
            $scope.cols = rst.data.rows;
            $scope.selOptions = rst.data.options;
            $scope.cols.forEach(function(d){
                d['editFlag'] = [1,1];
                if(d.type=="address"){
                    //// 地址联动组件，selProvince， selCity， selCounty为选择或设置的值
                    $scope.Addrs[d.field] = {"selProvince":"", "selCity":"", "selCounty":""};
                }
            });
            //// 加载地址控件
            loadAddrs($scope, $scope.Addrs);
            // loadDevice(-1);
            $scope.$apply();
        });
        function loadDevice(id){
            ajaxData("get_device", {"user":'David', "id":id}, function(rst){ cout(rst);
                var dt = rst.data, row = {};
                for(var col in dt){
                    $scope.line[col] = dt[col];
                    if(col in $scope.Addrs){
                        var ps =  [dt["province"], dt["city"], dt["county"]];
                        $scope.line[col+"_detail"] = dt[col];
                        //// 内置地址字段对应三个子字段，自定义则无
                        if(col!="address"){
                            ps = (dt[col] + "    ").split(" ");
                            $scope.line[col+"_detail"] = ps.slice(3).join("");
                        }cout(ps);
                        $scope.Addrs[col]["selProvince"] = ps[0];
                        $scope.Addrs[col]["selCity"] = ps[1];
                        $scope.Addrs[col]["selCounty"] = ps[2];
                    }
                }
                cout($scope.Addrs);
                cout($scope.line)
                $scope.$apply();
                return;                
            });    
        }
        

        function saveConfig(rows, sels){

        }

        //// address类型字段属系统默认的只记录详细地址_detail，其它的记录全部
        $scope.Submit = function(){
            SubmitRow($scope, $scope.line, function(){

            })
        };

    });


    app.directive('compile', function ($compile) {
        return function (scope, element, attrs) {
            scope.$watch(
              function (scope) {return scope.$eval(attrs.compile); },
              function (value) {
                  element.html(value);
                  $compile(element.contents())(scope);
              }
            );
        };
    });
    app.directive('onFinishRenderFilters', function ($timeout) {
        return {
            restrict: 'A',
            link: function ($scope, element, attr) {
                if ($scope.$last !== true)return;
                $timeout(function () {
                    $('.date').datetimepicker({
                        format: 'yyyy-mm-dd', language:'zh-CN', autoclose:true, minView:"month"
                    });
                 });
            }
        }
    });

    $(document).ready(function(){
        $('.date').datetimepicker({
            format: 'yyyy-mm-dd', language:'zh-CN', autoclose:true, minView:"month"
        });
    });

	</script>
			
			
</body>

</html>
